package cn.senjoeson.healthsport.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

public class MyPagerAdapter extends FragmentPagerAdapter {

        private List<Fragment> mFragmentList;
        private String[] tabTitles;

        public void setFragments(List<Fragment> fragments) {
            mFragmentList = fragments;
        }

        public void setTabTitles(String[] tabTitles) {
            this.tabTitles = tabTitles;
        }

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {

            return mFragmentList.get(position);


        }

        @Override
        public int getCount() {

            return mFragmentList.size();
        }

        //重写这个方法，将设置每个Tab的标题
        @Override
        public CharSequence getPageTitle(int position) {
            return tabTitles[position];
        }

    }